import request from '@/utils/request'

export default (path) => ({
  // 列表
  query(data) {
    return request({
      url: `/v1/purchase-demand/${path}/list`,
      method: 'post',
      data
    })
  },
  // 估算日销量规则设置
  saleRule(data) {
    return request({
      url: `/v1/purchase-demand/${path}/sale-rule`,
      method: 'post',
      data
    })
  },
  // 更新备货参数设置
  updateDemandRule(data) {
    return request({
      url: `/v1/purchase-demand/${path}/update-demand-rule`,
      method: 'post',
      data
    })
  },
  // 预估销量系数设置
  saleRatio(data) {
    return request({
      url: `/v1/purchase-demand/${path}/sale-ratio`,
      method: 'post',
      data
    })
  },
  // 批量设置补货状态
  notReplenishment(data) {
    return request({
      url: `/v1/purchase-demand/${path}/not-replenishment`,
      method: 'post',
      data
    })
  },
  // 设置活跃状态
  setActivation(data) {
    return request({
      url: `/v1/purchase-demand/${path}/set-activation`,
      method: 'post',
      data
    })
  },
  // 添加计划人员配置
  savePlan(data) {
    return request({
      url: `/v1/purchase-demand/${path}/save-plan`,
      method: 'post',
      data
    })
  },
  // 计划人员配置列表
  planList(data) {
    return request({
      url: `/v1/purchase-demand/${path}/plan-list`,
      method: 'post',
      data
    })
  },
  // 删除计划人员配置
  deletePlan(params) {
    return request({
      url: `/v1/purchase-demand/${path}/delete-plan`,
      method: 'get',
      params
    })
  },
  // 估算日销量
  estimateDaySale(params) {
    return request({
      url: `/v1/purchase-demand/${path}/estimate-day-sale`,
      method: 'get',
      params
    })
  },
  // 设置计划人员
  setPlan(data) {
    return request({
      url: `/v1/purchase-demand/${path}/set-plan`,
      method: 'post',
      data
    })
  },
  // 手动更新
  update() {
    return request({
      url: `/v1/purchase-demand/${path}/update`,
      method: 'get',
    })
  },
  // 单条更新
  updateSingle(data) {
    return request({
      url: `/v1/purchase-demand/${path}/update-single`,
      method: 'post',
      data
    })
  },
  // 销售趋势
  getSale(data) {
    return request({
      url: `/v1/purchase-demand/${path}/get-sale`,
      method: 'post',
      data
    })
  },
  // 导出日销量
  exportSale(data) {
    return request({
      url: `/v1/purchase-demand/${path}/export-day-sale`,
      method: 'post',
      responseType: 'blob',
      returnData: true,
      data,
    })
  },
  // 备料剩余数量
  purchaseOrder(data) {
    return request({
      url: `/v1/purchase-demand/${path}/get-purchase-plan`,
      method: 'post',
      data
    })
  },
  // 锁定库存
  lock(data) {
    return request({
      url: `/v1/purchase-demand/${path}/get-lock-order`,
      method: 'post',
      data
    })
  },
  // 创建备货计划
  createPlan(data) {
    return request({
      url: `/v1/purchase-demand/${path}/create-plan-detail`,
      method: 'post',
      data
    })
  },
  // 批量确认
  confirm(data) {
    return request({
      url: `/v1/purchase-demand/${path}/update-confirm-status`,
      method: 'post',
      data
    })
  },
  // 设置计划预估日销量
  planSale(data) {
    return request({
      url: `/v1/purchase-demand/${path}/update-plan-sale-num`,
      method: 'post',
      data
    })
  },
  // 更新补货数数量
  replenishment(data) {
    return request({
      url: `/v1/purchase-demand/${path}/update-replenishment`,
      method: 'post',
      data,
      returnData: true
    })
  },
  // 组合sku列表
  getGoodsSku(data) {
    return request({
      baseURL: window.APP_GETEWAY.goods,
      url: '/v1/goods/sku/list',
      method: 'post',
      data,
    })
  },
})
